<html>
<head>
<script type="text/javascript" src="src/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="src/js/jquery-ui.min.js"></script>
<link href="src/css/bootstrap-combined.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="src/js/bootstrap.min.js"></script>
<script type="text/javascript" src="src/js/getDB.js"></script>
</head>
<script language="javascript">
function insert(){
	$("#all").hide();
	$("#insert").show();
	}
function deletedata(){
	$("#all").hide();
	$("#delete").show();
	}
function insertweather(){
	$("#all").hide();
	$("#insertweather").show();
	}
function deleteweather(){
	$("#all").hide();
	$("#deleteweather").show();
	}
function backall(){
	$("#delete").hide();
	$("#deleteweather").hide();
	$("#insert").hide();
	$("#insertweather").hide();
	$("#all").show();
	}
function checkuser(){
	if(document.getElementById("username").value==""){
		alert("用户名不能为空！");
		return;
		}
	if(document.getElementById("password").value==""){
		alert("密码不能为空！");
		return;
		}
	}
function checkdDate(){
	if(document.getElementById("username-d").value==""){
		alert("用户名不能为空！");
		return;
		}
	}
function checkweather(){
	if(document.getElementById("Date").value==""){
		alert("日期不能为空！");
		return;
		}
	}
function checkdWeather(){
	if(document.getElementById("Date-d").value==""){
		alert("日期不能为空！");
		return;
		}
	}
</script>
<body>
<?php
				$username=$_POST['username'];
				$password=$_POST['password'];
				//获取用户登录数据
				
                $link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
                if($link)
                {
                    mysql_select_db(SAE_MYSQL_DB,$link);
                    //your code goes here	
                }
				$sql ='SELECT count(*) FROM login where username='.'"'.$username.'"'." and password=".'"'.$password.'"';
				 $result = mysql_query($sql)
                        or die(SQL语句执行失败);
				$row =mysql_fetch_row($result);
				if($row[0]=="1"){
					}
				else{
					echo '<script language="javascript">
							var hr = "http://yiyejinling.sinaapp.com/all/index.html";
							window.location = hr;
						  </script>
					';
					}


?>
<div align="center" id="insert" style="display:none;">
	<form action="insert.php" method="post" onSubmit="post">
    	新增用户名：<input type="text" id="username" name="username">
        <br><br>
        新增 密 码：<input type="password" id="password" name="password">
        <br><br>
        <input name="提交" type="submit" value="提交" onMouseOver="checkuser();">
        <input type="button" value="取消" onClick="backall();">    
    </form>
</div>

<div align="center" id="delete" style="display:none">
	<form action="delete.php" method="post" onSubmit="post">
    	要删除的用户名：<input type="text" id="username-d" name="username">
        <br><br>
        <input name="提交" type="submit" onMouseOver="checkdDate();" value="提交">
        <input type="button" value="取消" onClick="backall();">  
    </form>
</div>

<div align="center" id="insertweather" style="display:none;">
	<form action="insertweather.php" method="post" onSubmit="post">
    	新增日期：<input type="text" id="Date" name="Date">
        <br><br>
        新增天气：<input type="text" id="type" name="type">
        <br><br>
        新增高温：<input type="text" id="high" name="high">
        <br><br>
        新增低温：<input type="text" id="low" name="low">
        <br><br>
        <input name="提交" type="submit" onMouseOver="checkweather();" value="提交">
        <input type="button" value="取消" onClick="backall();">  
    </form>
</div>

<div align="center" id="deleteweather" style="display:none">
	<form action="deleteweather.php" method="post" onSubmit="post">
    	要删除的日期：<input type="text" id="Date-d" name="Date">
        <br><br>
        <input name="提交" type="submit" onClick="checkdWeather();" value="提交">
        <input type="button" value="取消" onClick="backall();">  
    </form>
</div>

<div id="all" class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<div class="row-fluid">
				<div class="span12">
					<h3 class="text-info">
                    <br>
                    <br>
						一叶·金陵 后台管理模块
					<br>
                    <br>
                    </h3>
				</div>
			</div>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span12">
			<div class="row-fluid">
				<div class="col-xs-6 span9">
					<table class="table" id="weather" style="display:none;">
						<thead>
							<tr>
								<th>
									日期
                                    <button class="btn btn-success" type="button" onClick="insertweather();">新增</button>
                    				<button class="btn btn-danger" type="button" onClick="deleteweather();">删除</button>
								</th>
							</tr>
						</thead>
						<tbody>
							<tr class="success">
                            
<?php
				
                $link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
                if($link)
                {
                    mysql_select_db(SAE_MYSQL_DB,$link);
                    //your code goes here	
                }
				$sql ='SELECT * FROM Nanjingweather';
				 $result = mysql_query($sql)
                        or die(SQL语句执行失败);
				$row =mysql_fetch_row($result);
				while($row =mysql_fetch_row($result)){
									echo '<td>'.$row[0].'</td>'.'<tr  class="success">'.'<td>'.$row[1].'</td>'.'</tr>'.'<tr  class="success">'.'<td>'.$row[2].'</td>'.'</tr>'.'<tr class="success">'.'<td>'.$row[3].'</td>'.'</tr>'.'<tr class="success">'.'<td>'.$row[4].'</td>'.'</tr>';
				}
					


?>
						</tbody>
					</table>
                    <table class="table" id="zhanghao" style="display:none;">
						<thead>
							<tr>
								<th>
									用户名
                                    <button class="btn btn-success" type="button" onClick="insert();">新增</button>
                            		<button class="btn btn-danger" type="button" onClick="deletedata();">删除</button>
								</th>
							</tr>
						</thead>
						<tbody>
							<tr class="success">
                    <?php
					
                        	   $link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
                				if($link)
                				{
                    			mysql_select_db(SAE_MYSQL_DB,$link);
                    			//your code goes here	
                				}
								$sql = 'select username from login;';
								$result = mysql_query($sql)
									or die(sql语句执行失败);
								while($row =mysql_fetch_row($result)){
									echo '<td>'.$row[0].'</td>'.'<tr  class="success">'.'<td>'.$row[1].'</td>'.'</tr>'.'<tr  class="success">'.'<td>'.$row[2].'</td>'.'</tr>'.'<tr class="success">'.'<td>'.$row[3].'</td>'.'</tr>'.'<tr class="success">'.'<td>'.$row[4].'</td>'.'</tr>';
									}
								
                                
                   ?>	<td>
                   			
							</td>
                            <td>
                            </td>
                            <td>
                            </td>
                            </tr>
						</tbody>
					</table>
				</div>
				<div class="col-xs-6 span3">
					<ul class="nav nav-list well">
						<li class="nav-header">
							列表标题
						</li>
						<li>
							<a href="#" onClick="showguanliyuan();">管理员帐户</a>
						</li>
						<li>
							<a href="#" onClick="showtianqi();">天气数据管理</a>
						</li>
					</ul>
				</div>
			</div>
			<div class="row-fluid">
				<div class="span12">
					 <span class="label" onClick="window.location = 'http://yiyejinling.sinaapp.com/all/index.html';">返回主页</span>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>